﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

using ScytheEngine;

namespace VTESGameLogicWindows
{
	public class TableArea : ScytheEngine.Object,
		ILoadable,
		IRenderable,
		IUpdateable
	{
		#region Members

		protected Texture2D m_BackGroundTexture;
		protected Rectangle m_BackGroundRectangle;
		protected Viewport m_Viewport;

		#endregion

		#region ILoadable Members

		public void LoadContent( GraphicsDevice gfxDev, ContentManager loader )
		{
			ContentManager background_images_content = new ContentManager( loader.ServiceProvider, "Content" );
			m_BackGroundTexture = background_images_content.Load<Texture2D>( "cardsbackground" );
		}

		public virtual void LoadCustomContent()
		{

		}

		#endregion

		#region IRenderable Members

		public void Render( GraphicsDevice gfxDev )
		{
			m_Viewport = gfxDev.Viewport;

			SpriteBatch spriteBatch = new SpriteBatch( gfxDev );

			spriteBatch.Begin( SpriteBlendMode.AlphaBlend );

			m_BackGroundRectangle = new Rectangle( 
				(int)m_Position.X - m_BackGroundTexture.Width/2, (int)m_Position.Y - m_BackGroundTexture.Height/2,
				m_BackGroundTexture.Width, m_BackGroundTexture.Height );
			spriteBatch.Draw( m_BackGroundTexture, m_BackGroundRectangle, null, Color.White );

			spriteBatch.End();
		}

		#endregion

		#region IUpdateable Members

		public bool Enabled
		{
			get { return true; }
		}

		public event EventHandler  EnabledChanged;

		public void Update( GameTime gameTime )
		{
			UpdateChild( gameTime );
		}

		public virtual void UpdateChild( GameTime gameTime )
		{

		}

		public int UpdateOrder
		{
			get { return 0; }
		}

		public event EventHandler  UpdateOrderChanged;

		#endregion
	}
}
